﻿<%@ Page Title="AGR: Subjects" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Subjects.aspx.cs" Inherits="AGR.Web.Pages.Courses.Subjects" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="RightContent" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">

    <h3>Subjects</h3>
    <hr />

    <asp:UpdatePanel ID="SubjectsUpdatePanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>

        <table>
            <tr>
                <td>Search:</td>
                <td>
                    <asp:TextBox ID="txtSearchSubject" runat="server" CssClass="textbox-small"></asp:TextBox>
                </td>
                <td>
                    <asp:Button ID="btnSearchSubject" runat="server" Text="Search" CssClass="button" 
                        onclick="btnSearchSubject_Click" />
                    <asp:Button ID="btnSearchClear" runat="server" Text="Clear" CssClass="button"
                         OnClick="btnSearchClear_Click" />
                </td>
            </tr>
        </table>

        <br />

        <table>
            <tr>
                <td>
                    <asp:Button ID="btnAddSubject" runat="server" Text="Add" CssClass="button"
                        onclick="btnAddSubject_Click" />
                    <asp:Button ID="btnDeleteSubject" runat="server" Text="Remove" CssClass="button"
                     OnClick="btnSubjectDelete_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:GridView ID="SubjectGridView" runat="server" CssClass="table-grid" AlternatingRowStyle-CssClass="odd" FooterStyle-CssClass="table-grid-footer"
                    EmptyDataRowStyle-CssClass="empty" EmptyDataText="No subjects found." PagerStyle-CssClass="pager"
                    DataKeyNames="SubjectCode"
                    AutoGenerateColumns="False" onrowcommand="SubjectGridView_OnRowCommand"
                    onrowcancelingedit="SubjectGridView_RowCancelingEdit" onrowediting="SubjectGridView_RowEditing" onrowupdating="SubjectGridView_RowUpdating" 
                    onpageindexchanging="SubjectGridView_PageIndexChanging"
                    AllowPaging="True" PageSize="10">
                        <PagerSettings Mode="NumericFirstLast" Position="Bottom"/>
                        <Columns>
                            <asp:TemplateField HeaderText="Select" HeaderStyle-Width="40px" 
                             HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkSelect" runat="server" CausesValidation="False"> </asp:CheckBox>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:CheckBox ID="chkSelect" runat="server" Enabled="false" CausesValidation="False"> </asp:CheckBox>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <strong>Add</strong>
                                </FooterTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Options" HeaderStyle-Width="80px" HeaderStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkSubjectDetails" runat="server" CausesValidation="False" Text="Details" CommandName="Select" />
                                    &nbsp;
                                    <asp:LinkButton ID="lnkSubjectEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:LinkButton ID="lnkSubjectCancel" runat="server" CausesValidation="False"  CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                                    &nbsp;
                                    <asp:LinkButton ID="lnkSubjectUpdate" runat="server" CausesValidation="True" CommandName="Update" Text="Update"
                                        ValidationGroup="SubjectUpdateValidationGroup"></asp:LinkButton>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:LinkButton ID="btnSubjectCancel" runat="server" Text="Cancel" CausesValidation="false" UseSubmitBehavior="false" CommandName="CancelInsert" />
                                    &nbsp;
                                    <asp:LinkButton ID="btnSubjectInsert" runat="server" Text="Save" UseSubmitBehavior="false" CommandName="Insert"
                                        ValidationGroup="SubjectSaveValidationGroup" />
                                </FooterTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Subject Code" HeaderStyle-Width="70px">
                                <ItemTemplate><%# Eval("SubjectCode")%></ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtSubjectCode" runat="server" Text='<%# Eval("SubjectCode")%>' Width="60px" Enabled="false"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtSubjectCode" ID="SubjectCodeValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectUpdateValidationGroup" ></asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="txtSubjectCode" runat="server" Width="60px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="SubjectCodeValidator" runat="server" ErrorMessage=" * " Display="Dynamic" CssClass="ClassValidator"
                                        ControlToValidate="txtSubjectCode" ValidationGroup="SubjectSaveValidationGroup"></asp:RequiredFieldValidator>
                                </FooterTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Type" HeaderStyle-Width="60px">
                                <ItemTemplate><%# Eval("Type")%></ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtType" runat="server" Text='<%# Eval("Type")%>' Width="50px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtType" ID="CourseNameValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectUpdateValidationGroup" ></asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="txtType" runat="server" Width="50px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtType" ID="CourseNameValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator"  ValidationGroup="SubjectSaveValidationGroup" ></asp:RequiredFieldValidator>
                                </FooterTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Title" HeaderStyle-Width="80px">
                                <ItemTemplate><%# Eval("Title")%></ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtTitle" runat="server" Text='<%# Eval("Title")%>' Width="70px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtTitle" ID="TitleValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectUpdateValidationGroup" ></asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="txtTitle" runat="server" Width="70px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="TitleValidator" runat="server" ErrorMessage=" * " Display="Dynamic" CssClass="ClassValidator"
                                        ControlToValidate="txtTitle"  ValidationGroup="SubjectSaveValidationGroup"></asp:RequiredFieldValidator>
                                </FooterTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Description" HeaderStyle-Width="250px">
                                <ItemTemplate><%# Eval("Description")%></ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtDescription" runat="server" Text='<%# Eval("Description")%>' Width="240px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtDescription" ID="DescriptionValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectUpdateValidationGroup" ></asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="txtDescription" runat="server" Width="240px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtDescription" ID="DescriptionValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectSaveValidationGroup" ></asp:RequiredFieldValidator>
                                </FooterTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="NQF" HeaderStyle-Width="35px">
                                <ItemTemplate><%# Eval("NQFLevel")%></ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtNQFLevel" runat="server" Text='<%# Eval("NQFLevel")%>' Width="25px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtNQFLevel" ID="NQFLevelValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectUpdateValidationGroup" ></asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="txtNQFLevel" runat="server" Width="25px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtNQFLevel" ID="NQFLevelValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectSaveValidationGroup" ></asp:RequiredFieldValidator>
                                </FooterTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Credits" HeaderStyle-Width="35px">
                                <ItemTemplate><%# Eval("Credits")%></ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtCredits" runat="server" Text='<%# Eval("Credits")%>' Width="25px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtCredits" ID="CreditsValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectUpdateValidationGroup" ></asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="txtCredits" runat="server" Width="25px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtCredits" ID="CreditsValidator" runat="server" ErrorMessage=" * " 
                                        Display="Dynamic" CssClass="ClassValidator" ValidationGroup="SubjectSaveValidationGroup" ></asp:RequiredFieldValidator>
                                </FooterTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle HorizontalAlign="Right" Wrap="False" />
                    </asp:GridView>
                </td>
            </tr>
        </table>

    </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
